import React from 'react'
import { render, unmountComponentAtNode } from 'react-dom' // eslint-disable-line
import { AppContainer } from 'react-hot-loader'
import App from './containers/App/app'
import configureStore from './store'
import rootSagas from './rootSagas'

import './css/style.css' // eslint-disable-line
import 'media/iconfont/iconfont.css' // eslint-disable-line

const store = configureStore()
rootSagas.map(store.runSaga)

const renderApp = (NextApp) => { 
  render(
    <AppContainer>
      <NextApp store={store} />
    </AppContainer>,
    document.querySelector('[data-js="app"]')
  )
}

renderApp(App)

if (module.hot) {
  module.hot.accept('./containers/App/app', () => {
    const NextApp = require('./containers/App/app').default
    //  unmountComponentAtNode(document.querySelector('[data-js="app"]')); //据说能更新reducers
    renderApp(NextApp)
  })
}
